<template>
	<view>
		<commonHeader :title="titles"></commonHeader>
		<view class="gHeadbox"></view>
		<view class="record">
			<view class="record_box">
				<view class="box_item" v-for="(item,index) in lisyt" :key="index" @click.stop="toNoticeDetail(item.id)">
					<view class="">
						<view class="item_a">
							{{item.title}}
						</view>
						<view class="item_num">
							{{item.createTime}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-empty v-if="lisyt.length<=0" mode="data" icon="data" :text="$t('in1')" iconSize="200" ntextSize="28" marginTop="80"></u-empty>
	</view>
</template>

<script>
	import {
		noticeList
	} from '@/api/home.js'
	export default {
		data() {
			return {
				ntype: '', //类型
				page: 1,
				pageSize: 100,
				lisyt: [], //数据
				noMoreData: false, // 没有更多数据了
				titles: this.$t('in2'),
			}
		},
		mounted() {
			this.fnmemberAccountLog()
		},
		// 上拉加载
		onReachBottom() {
			console.log(this.noMoreData)
			// if (this.noMoreData) {
			// 	this.page++;
			// 	this.fnmemberAccountLog(); // 获取的数据列表
			// }
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option.type); //打印出上个页面传递的参数。
			if (option.type) {
				this.ntype = option.type;
				this.titles = option.names
			}
		},
		methods: {
			toNoticeDetail(tid) {
				let names;
				if (this.ntype == 1) {
					names = this.$t('in3')
				} else {
					names = this.$t('in4')
				}
				uni.navigateTo({
					url: '/pages/index/notice/item/item?tid=' + tid + '&names=' + names
				})
			},
			fnmemberAccountLog() {
				var langs = uni.getStorageSync('language') || 'zh';
				if (langs == 'zh-Hans' || langs == 'zh-Hant') {
					langs = 'zh'
				}
				var params = {
					type: this.ntype,
					page: this.page,
					pageSize: this.pageSize,
					lang: langs
				}
				noticeList(params).then(res => {
					if (res.code == 200) {
						console.log(res)
						const infoList = res.data
						this.noMoreData = false;
						if (infoList) {
							this.noMoreData = true;
							this.lisyt = this.lisyt.concat(infoList)
						} else {
							this.noMoreData = false;
						}
					}
				})
			},
		},
	}
</script>

<style scoped lang="scss">
	.record {
		padding: 30rpx;
		box-sizing: border-box;

		&_box {
			.box_item {
				width: 100%;
				border-radius: 24rpx;
				opacity: 1;
				background: linear-gradient(137deg, #65008275 0%, #20005e63 100%);
				box-shadow: inset 0 2rpx 6rpx 0 rgba(69, 69, 69, 0.54), inset 0 0 16rpx 0 rgba(255, 255, 255, 0.23), 4rpx 4rpx 20rpx 0 rgba(0, 0, 0, 0.22);
				padding: 24rpx 40rpx;
				box-sizing: border-box;
				margin-bottom: 20rpx;
				backdrop-filter: blur(8px);

				.item_a {
					color: rgb(255, 255, 255);
					font-size: 30rpx;
				}

				.item_num {
					color: #baa7c6;
					font-size: 22rpx;
				}

				.item_boxbom {
					margin-top: 18rpx;

					.item_time {
						color: rgb(182, 182, 182);
						font-size: 26rpx;
					}

					.item_usdt {
						color: rgb(182, 182, 182);
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>